package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.goodsbrand.GoodsBrandBO;
import com.micro.modual.model.dto.goodsbrand.GoodsBrandDetailDTO;
import com.micro.modual.model.dto.goodsbrand.GoodsBrandListDTO;
import com.micro.modual.service.GoodsBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <h1>商品品牌表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "品牌管理",tags = "品牌管理")
@RestController
@RequestMapping(value = "goodsBrand")
public class GoodsBrandController {

    @Autowired
    private GoodsBrandService goodsBrandService;

    /**
     * <h2>查找商品品牌表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<GoodsBrandListDTO> {@link GoodsBrandListDTO}s  商品品牌表 列表返回对象
     */
    @ApiOperation(value = "查询商品品牌表列表" ,notes = "查询商品品牌表列表")
    @GetMapping(value = "/findGoodsBrandList")
    public RespJsonPageData<GoodsBrandListDTO> findGoodsBrandList(@RequestParam  Map<String,Object> params){
        return goodsBrandService.findList(params,GoodsBrandListDTO.class);
    }

    /**
     * <h2>根据主键编号查看商品品牌表详情</h2>
     * @param id  商品品牌表 主键编号
     * @return {@link GoodsBrandDetailDTO}  商品品牌表 详情
     */
    @ApiOperation(value = "查询商品品牌表详情",notes = "根据主键编号，查询商品品牌表详情")
    @GetMapping(value = "/findGoodsBrandDetail/{id}")
    public RespJsonData<GoodsBrandDetailDTO> findGoodsBrandDetail(@PathVariable("id") Long id){
        return goodsBrandService.findDetail(id,GoodsBrandDetailDTO.class);
    }

    /**
     * <h2>新增商品品牌表详情</h2>
     * @param goodsBrandBO {@link GoodsBrandBO} 商品品牌表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增商品品牌表",notes = "新增商品品牌表")
    @PostMapping(value = "/addGoodsBrand")
    public RespJson addGoodsBrand(@RequestBody GoodsBrandBO goodsBrandBO){
        return goodsBrandService.addGoodsBrand(goodsBrandBO);
    }

    /**
     * <h2>修改商品品牌表详情</h2>
     * @param goodsBrandBO  {@link GoodsBrandBO} 商品品牌表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改商品品牌表",notes = "修改商品品牌表")
    @PostMapping(value = "/editGoodsBrand")
    public RespJson editGoodsBrand(@RequestBody GoodsBrandBO goodsBrandBO){
        return goodsBrandService.editGoodsBrand(goodsBrandBO);
    }

    /**
     * <h2>根据主键编号删除商品品牌表信息</h2>
     * @param id  商品品牌表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除商品品牌表",notes = "根据地址ID，删除商品品牌表")
    @PostMapping(value = "/deleteGoodsBrand/{id}")
    public RespJson deleteGoodsBrand(@PathVariable("id") Long id){
        return goodsBrandService.deleteGoodsBrand(id);
    }

    /**
     * <h2>查询所有可用品牌</h2>
     * @return
     */
    @GetMapping(value = "/findBrandList")
    public RespJsonData<List<GoodsBrandDetailDTO>> findBrandList(){
        return goodsBrandService.findBrandList();
    }
}

